/*
 * @Descripttion   
 * @version        
 * @Author        
 * @Date           2021-07-06
 * @LastEditors    
 * @LastEditTime   2021-07-06
 */
#include "MyEngine.h"
#include "MYPINLINE.h"
Servo servo_pin_13;
Servo servo_pin_4;
int angleD = 90;
int j;
int angleDoor = servo_pin_13.read();

void doorMove(int angle)
{
  servo_pin_13.attach(engine);
  servo_pin_13.write(0);

    static int num = 0;
    int count;
    bool t = false;
    
    angleD = angle;
    //Serial.println("11");
             for(j=0;j<angle;j++){
                servo_pin_13.write(j);
                delay(1);
             }
            delay(10000);
            //Serial.println("1");
            for(j=angle;j>0;j--){
                servo_pin_13.write(j);
                delay(1);
             }

}
int autoDoor(char num){
int key;
   servo_pin_4.attach(engine2);
   servo_pin_4.write(0);
  if(num == '1')
  {
      //Serial.println("1");
      openWindow();
      key=1;
  }
   else{     
        closeWindow();
        key=0;
        }
   return key;
}

void openWindow()
{
    for(j=0;j<=90;j++){
                servo_pin_4.write(j);
                delay(1);
    }
}


void closeWindow()
{
    for(j=90;j>0;j--){
                servo_pin_4.write(j);
                delay(1);
     }
}


void Doorinit()
{          
  //servo_pin_13.attach(engine);
  //servo_pin_13.write(0);

}
